package com.gti.mobilsafe.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import android.content.Context;

public class CopyAssetUtil {
    
	public static File copyFile(Context context,String fileName,File desFile){
		FileOutputStream fileOutputStream = null;
		InputStream is  = null;
		try {
			is  = context.getAssets().open(fileName);
			fileOutputStream = new FileOutputStream(desFile);
			byte[] bytes = new byte[1024];
			int len = 0;
			while((len = is.read(bytes))!=-1){
				
				fileOutputStream.write(bytes,0,len);
				
			}
			
		} catch (IOException e) {
			
			e.printStackTrace();
		}finally{
			try {
				fileOutputStream.close();
				is.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
		}
		return desFile;
	}
}
